package cn.wolfcode.shiro;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.Configuration;
import freemarker.template.TemplateException;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import java.io.IOException;

//给freemarker的配置类进行增强让其能用shiro标签
public class MyFreeMarkerConfig extends FreeMarkerConfigurer {
    @Override
    public void afterPropertiesSet() throws IOException, TemplateException {
        //调用父类让其完成属性配置
        super.afterPropertiesSet();
        //获取设置好的配置加东西
        Configuration cfg = this.getConfiguration();
        //加shiro标签
        cfg.setSharedVariable("shiro", new ShiroTags());
    }
}
